/* 
 * File:   Ball.cpp
 * Author: jose
 * 
 * Created on 5 de Abril de 2012, 20:20
 */

#include "Ball.h"

#include <iostream>

Ball::Ball(std::string filename) {
    ballImage = SdlUtils::loadImage(filename);
    posX = posY = velX = velY = 0;
}

Ball::Ball(const Ball& orig) {
}

Ball::~Ball() {
}

void Ball::move(Uint32 deltaTicks){

    
    
    if(velX == 0)
    {
        velX = Ball::initialBallspeed;
    }
    
    //posX += velX * ( deltaTicks / 1000.f );
    posX += ( velX * ( deltaTicks / 1000.f ) );
    posY += velY * ( deltaTicks / 1000.f );
    /*
    if(posX <=0)
    {
        posX = 0;
    }
    else if( posX + ballImage->clip_rect.w > GameDefinitions::SCREEN_WIDTH )
    {
        posX = GameDefinitions::SCREEN_WIDTH - ballImage->clip_rect.w;    
    }
    
    if( posY < 0 )
    {
        posY = 0;    
    }
    else if( posY + ballImage->clip_rect.h > GameDefinitions::SCREEN_HEIGHT )
    {
        posY = GameDefinitions::SCREEN_HEIGHT - ballImage->clip_rect.h;    
    }
    */
    if((posX+ballImage->clip_rect.w > GameDefinitions::SCREEN_WIDTH) || (posX <= 0))
        velX *= -1;    

}

